<template>
	<view>
		<detailPage
			:pageUrl="pageUrl"
			:editFormOptions="editFormOptions"
			:editFormFields="editFormFields"
			:detailColumns="detailColumns"
			@masterDate="masterDate"
			:titel="titel"
		></detailPage>
	</view>
</template>
<script>
export default {
	data() {
		return {
			titel: '',
			pageUrl: 'q_warehouse_allot',
			editFormFields: {
				Coding: '',
				Goods_num: '',
				WHSE_name_out: '',
				WHSE_name_in: ''
			},
			editFormOptions: [
				{
					title: 'ID',
					required: true,
					field: 'Allot_id',
					hidden: true,
					readonly: true
				},
				{
					title: '单据编码',
					field: 'Coding',
					readonly: true
				},
				{
					title: '调出数量',
					field: 'Goods_num',
					readonly: true
				},
				{
					title: '调出机构',
					field: 'WHSE_name_out',
					readonly: true,
					data: [],
					key: '一级仓库'
				},
				{
					title: '调入机构',
					field: 'WHSE_name_in',
					readonly: true,
					data: [],
					key: '一级仓库'
				}
			],
			detailColumns: [
				{
					field: 'Allot_list_id',
					title: 'ID',
					hidden: true
				},
				{
					field: 'Goods_sub',
					title: '商品编码	',
					type: 'string',
					readonly: true
				},
				{
					field: 'Goods_name',
					title: '商品名称',
					type: 'string',
					readonly: true
				},
				{
					field: 'Goods_size',
					title: '规格型号',
					readonly: true
				},
				{
					field: 'AvailableQuantity',
					title: '可用数量',
					readonly: true
				},
				{
					field: 'Goods_num',
					title: '调出数量',
					readonly: true
				},
				{
					field: 'WHSE_name_out',
					title: '调出库位',
					readonly: true,
					data: [],
					key: '库位编码',
					type: 'select'
				},
				{
					field: 'WHSE_name_in',
					title: '调入库位',
					readonly: true,
					data: [],
					key: '库位编码',
					type: 'select'
				},
				{
					field: 'Remark',
					title: '备注',
					readonly: true
				}
			]
		};
	},
	onLoad() {
		this.detailColumns.forEach((obj) => {
			if (obj.type == 'select') {
				this.http.post('api/Sys_Dictionary/GetVueDictionary', [obj.key], true).then((result) => {
					if (result.length) {
						console.log('result', result);
						for (var index = 0; index < result.length; index++) {
							if (result[index].dicNo == obj.key) {
								obj.data = result[index].data;
								console.log('obj.data', obj.data);
							}
						}
					}
				});
			}
		});
	},
	methods: {
		masterDate(val) {
			Object.assign(this.editFormFields, val);
		}
	}
};
</script>
